<template>
    <van-nav-bar v-show="isUserAgent" :title="title">
        <template #left>
            <van-icon name="cross" size="24" @click="toIndex" />
        </template>
    </van-nav-bar>
</template>
<script>
    export default {
        props:["title"],
        name: "m_blockIndexNavBar",
        data: function(){
            return {
                isUserAgent: false
            }
        },
        mounted(){
            let that = this;
            if(Env.UserAgent === 'dingTalk'){
                dd.ready(function () {
                    dd.biz.navigation.setTitle({
                        title : that.title
                    });
                    dd.biz.navigation.setMenu({
                        textColor : "#ADD8E611",
                        items : [
                            {
                                "id":"exit",
                                "text":"首页",
                                "url": require("../assets/logout.png")
                            },
                            {
                                "id":"refresh",
                                "text":"刷新",
                                "url": require("../assets/refresh.png")
                            }
                        ],
                        onSuccess: function(data) {
                            if(data.id=='exit'){
                                that.toIndex();
                            }else if(data.id=='refresh'){
                                that.refresh();
                            }
                        }
                    });
                });
            }else{
                this.isUserAgent = true;
            }
        },
        methods:{
            toIndex(){
                location.href = "/";
            },
            refresh(){
                location.reload();
            }
        }
    }
</script>